package com.zc.zby.basicframedemo.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.zc.zby.basicframedemo.R;
import com.zc.zby.basicframedemo.base.RxBaseActivity;
import com.zc.zby.basicframedemo.model.MovieModel;
import com.zc.zby.basicframedemo.network.BaseEntity;
import com.zc.zby.basicframedemo.network.BaseObserver;
import com.zc.zby.basicframedemo.network.RetrofitFactory;

import butterknife.OnClick;
import io.reactivex.Observable;

public class RxJavaRetrofitActivity extends RxBaseActivity {

    @Override
    public int getLayoutId() {
        return R.layout.activity_rx_java_retrofit;
    }

    @Override
    public void initViews(Bundle savedInstanceState) {
    }

    @Override
    public void setListeners() {

    }

    @Override
    public void initToolBar() {

    }

    @Override
    public void initData() {

    }

    @OnClick(R.id.bt)
    protected void OnClick(View view) {
        Observable<BaseEntity<MovieModel>> observable = RetrofitFactory.getInstance().postLogin("tianna", "123456", true);
        asynObserable(observable, new BaseObserver<MovieModel>(getApplicationContext()) {
            @Override
            protected void onHandleSuccess(MovieModel movieModel) {
                Toast.makeText(getApplication(), movieModel.getName() + " 登录成功", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
